<template>
  <div class="collect">
    <ul class="list" v-if="collectGoodsList.length">
      <router-link
        tag="li"
        v-for="item in collectGoodsList"
        :key="item.id"
        :to="`/goods/goodsdetail?id=${item.id}`"
      >
        <img :src="item.list_pic_url" alt="" />
        <p class="name">{{ item.name }}</p>
        <p class="price">￥{{ item.retail_price }}</p>
      </router-link>
    </ul>
    <div class="empty" v-else>
      <van-empty description="暂无收藏" />
    </div>
  </div>
</template>
<script>
import { listAction } from "@/api/mine/collect/index";
export default {
  data() {
    return {
      collectGoodsList: [],
    };
  },
  methods: {
    // 获取收藏列表
    async getCollectList() {
      const { collectGoodsList } = await listAction({
        openId: localStorage.getItem("openId"),
      });
      this.collectGoodsList = collectGoodsList;
    },
  },
  created() {
    this.getCollectList();
  },
};
</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
